package com.tanhua.app.controller;

import com.tanhua.app.service.SettingsService;
import com.tanhua.db.Settings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/users")
public class SettingsController {

    @Autowired
    private SettingsService settingsService;

    @GetMapping(value = "/settings",name="通用设置--查询问题/通知")
    public ResponseEntity findSettings(){
        return settingsService.findSettings();
    }

    @PostMapping(value = "/questions", name="通用设置--新增or修改问题")
    public ResponseEntity updateQuestions(@RequestBody Map<String,String> map){
        String content = map.get("content");
        return settingsService.updateQuestions(content);
    }

    @PostMapping(value = "/notifications/setting", name="通用设置--新增or修改通知")
    public ResponseEntity updateSetting(@RequestBody Settings settings){
        return settingsService.updateSetting(settings);
    }

    @GetMapping(value = "/blacklist", name="当前用户的黑名单分页展示")
    public ResponseEntity findBlackList(Integer page,Integer pagesize){
        return settingsService.findBlackList(page,pagesize);
    }


    @DeleteMapping(value = "/blacklist/{uid}", name="删除黑名单")
    public ResponseEntity removeBlackList(@PathVariable("uid") String blackid){
        return settingsService.removeBlackList(blackid);
    }

}
